package com.naire.modul.projeckpi.action;

import java.util.ArrayList;
import java.util.List;

import net.common.action.GeneralAction;

import com.naire.modul.projeckpi.service.ProjeckpiDeleteService;
import com.naire.modul.projeckpi.service.ProjeckpiEditorService;
import com.naire.modul.projeckpi.service.ProjeckpiFindService;
import com.naire.modul.projeckpi.service.ProjeckpiSearchService;
import com.naire.modul.projeckpi.service.ProjeckpiSourceService;
import com.naire.modul.projeckpi.vo.ProjeckpiVo;

public class ProjeckpiAction extends GeneralAction {

	private static final long serialVersionUID = 7127573666355745443L;

	private ProjeckpiVo bean = new ProjeckpiVo();
	private List<ProjeckpiVo> list = new ArrayList<ProjeckpiVo>();
	private String parent_code;
	
	public void changeSource() throws Exception {
		ProjeckpiSourceService service = new ProjeckpiSourceService();
		service.setBean(bean);
		service.invoke();
	}
	
	public String jsonSearch() throws Exception {
		ProjeckpiSearchService service = new ProjeckpiSearchService();
		service.setPageBean(null);
		service.setProject_id(bean.getProject_id());
		service.setParent_code(parent_code);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}

	public String search() throws Exception {
		ProjeckpiSearchService service = new ProjeckpiSearchService();
		service.setPageBean(null);
		service.setProject_id(bean.getProject_id());
		service.setParent_code(parent_code);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}

	public String editor() throws Exception {
		ProjeckpiEditorService service = new ProjeckpiEditorService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}

	public String find() throws Exception {
		if (bean.getProject_kpi_id() != null) {
			ProjeckpiFindService service = new ProjeckpiFindService();
			service.setId(bean.getProject_kpi_id());
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}

	public String delete() throws Exception {
		ProjeckpiDeleteService service = new ProjeckpiDeleteService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}

	public ProjeckpiVo getBean() {
		return bean;
	}

	public void setBean(ProjeckpiVo bean) {
		this.bean = bean;
	}

	public List<ProjeckpiVo> getList() {
		return list;
	}

	public void setList(List<ProjeckpiVo> list) {
		this.list = list;
	}

	public String getParent_code() {
		return parent_code;
	}

	public void setParent_code(String parent_code) {
		this.parent_code = parent_code;
	}
}
